<template>
  <div class="under-development-container">
    <div class="under-development-content">
      <!-- 开发中图标区域 -->
      <div class="icon-section">
        <div class="construction-wrapper">
          <el-icon class="construction-icon" size="80">
            <Tools />
          </el-icon>
          <div class="progress-dots">
            <span class="dot" :class="{ active: animationStep >= 1 }"></span>
            <span class="dot" :class="{ active: animationStep >= 2 }"></span>
            <span class="dot" :class="{ active: animationStep >= 3 }"></span>
          </div>
        </div>
      </div>
      
      <!-- 标题和描述 -->
      <div class="message-section">
        <h1 class="title">功能开发中</h1>
        <p class="description">
          该功能正在紧锣密鼓地开发中，敬请期待！
          <br>
          我们正在努力为您打造更好的用户体验。
        </p>
        
        <!-- 预期完成时间 -->
        <div class="timeline-info">
          <el-icon class="calendar-icon"><Calendar /></el-icon>
          <span>预计完成时间：{{ expectedDate }}</span>
        </div>
      </div>
      
      <!-- 进度指示器 -->
      <div class="progress-section">
        <div class="progress-label">开发进度</div>
        <el-progress 
          :percentage="developmentProgress" 
          :color="progressColor"
          :stroke-width="8"
          class="custom-progress">
        </el-progress>
      </div>
      
      <!-- 操作按钮区域 -->
      <div class="action-section">
        <el-button 
          type="primary" 
          class="idoo-details-add" 
          size="large"
          @click="goHome">
          <el-icon class="mr-2"><House /></el-icon>
          返回首页
        </el-button>
        <el-button 
          class="idoo-details-button" 
          size="large"
          @click="subscribeNotification">
          <el-icon class="mr-2"><Bell /></el-icon>
          完成时提醒我
        </el-button>
      </div>
      
      <!-- 相关功能推荐 -->
      <div class="suggestions-section">
        <h3 class="suggestions-title">您可能感兴趣的功能</h3>
        <div class="suggestions-grid">
          <div 
            v-for="suggestion in suggestions" 
            :key="suggestion.id"
            class="suggestion-item"
            @click="navigateToSuggestion(suggestion)">
            <el-icon class="suggestion-icon">
              <component :is="suggestion.icon" />
            </el-icon>
            <span class="suggestion-text">{{ suggestion.name }}</span>
          </div>
        </div>
      </div>
      
      <!-- 底部信息 -->
      <div class="footer-info">
        <p class="update-info">
          <el-icon class="update-icon"><Refresh /></el-icon>
          最后更新：{{ lastUpdateTime }}
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import { ref, onMounted, onUnmounted } from 'vue'
import { ElMessage } from 'element-plus'
import { 
  House, 
  Bell, 
  Tools, 
  Calendar, 
  Refresh,
  DataLine,
  Setting,
  Document
} from '@element-plus/icons-vue'

export default {
  name: 'UnderDevelopment',
  components: {
    House,
    Bell,
    Tools,
    Calendar,
    Refresh,
    DataLine,
    Setting,
    Document
  },
  props: {
    // 可以通过props传入特定的功能名称和进度
    featureName: {
      type: String,
      default: '新功能'
    },
    progress: {
      type: Number,
      default: 65
    },
    expectedDate: {
      type: String,
      default: '2024年第一季度'
    }
  },
  setup(props) {
    const animationStep = ref(0)
    const developmentProgress = ref(props.progress)
    const lastUpdateTime = ref('')
    
    let animationInterval = null
    
    // 进度条颜色
    const progressColor = ref([
      { color: '#f56c6c', percentage: 20 },
      { color: '#e6a23c', percentage: 40 },
      { color: '#6f7ad3', percentage: 60 },
      { color: '#1989fa', percentage: 80 },
      { color: '#714B67', percentage: 100 }
    ])
    
    // 功能建议
    const suggestions = ref([
      {
        id: 1,
        name: '数据可视化',
        icon: 'DataLine',
        route: '/visualization'
      },
      {
        id: 2,
        name: '系统设置',
        icon: 'Setting',
        route: '/settings'
      },
      {
        id: 3,
        name: '帮助文档',
        icon: 'Document',
        route: '/help'
      }
    ])
    
    // 动画效果
    const startAnimation = () => {
      animationInterval = setInterval(() => {
        animationStep.value = (animationStep.value + 1) % 4
      }, 800)
    }
    
    const stopAnimation = () => {
      if (animationInterval) {
        clearInterval(animationInterval)
        animationInterval = null
      }
    }
    
    // 获取当前时间
    const updateLastTime = () => {
      const now = new Date()
      lastUpdateTime.value = now.toLocaleString('zh-CN')
    }
    
    const goHome = () => {
      window.location.href = '/'
    }
    
    const subscribeNotification = () => {
      ElMessage.success('已订阅完成提醒，我们会在功能上线时通知您！')
    }
    
    const navigateToSuggestion = (suggestion) => {
      ElMessage.info(`正在跳转到${suggestion.name}...`)
      // 这里可以添加路由跳转逻辑
      // this.$router.push(suggestion.route)
    }
    
    onMounted(() => {
      startAnimation()
      updateLastTime()
    })
    
    onUnmounted(() => {
      stopAnimation()
    })
    
    return {
      animationStep,
      developmentProgress,
      progressColor,
      suggestions,
      lastUpdateTime,
      expectedDate: props.expectedDate,
      goHome,
      subscribeNotification,
      navigateToSuggestion
    }
  }
}
</script>

<style scoped>
.under-development-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f1edf0 0%, #e8e0e5 100%);
  padding: 20px;
}

.under-development-content {
  text-align: center;
  background: white;
  border-radius: 16px;
  padding: 50px 40px;
  box-shadow: 0 10px 30px rgba(113, 75, 103, 0.1);
  max-width: 700px;
  width: 100%;
}

.icon-section {
  margin-bottom: 30px;
}

.construction-wrapper {
  position: relative;
  display: inline-block;
}

.construction-icon {
  color: #714B67;
  margin-bottom: 20px;
  animation: bounce 2s infinite;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #ddd;
  transition: background-color 0.3s ease;
}

.dot.active {
  background-color: #922575;
}

.message-section {
  margin-bottom: 30px;
}

.title {
  font-size: 28px;
  font-weight: 600;
  color: #714B67;
  margin: 0 0 20px 0;
  font-family: "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

.description {
  font-size: 16px;
  color: #666;
  line-height: 1.6;
  margin: 0 0 20px 0;
}

.timeline-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgb(1, 128, 165);
  font-weight: 500;
  font-size: 14px;
}

.calendar-icon {
  font-size: 16px;
}

.progress-section {
  margin-bottom: 40px;
}

.progress-label {
  font-size: 14px;
  color: #714B67;
  font-weight: 600;
  margin-bottom: 10px;
}

.custom-progress {
  margin: 0 auto;
  max-width: 300px;
}

.action-section {
  margin-bottom: 40px;
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.suggestions-section {
  margin-bottom: 30px;
}

.suggestions-title {
  font-size: 18px;
  color: #714B67;
  margin-bottom: 20px;
  font-weight: 600;
}

.suggestions-grid {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.suggestion-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid #f0f0f0;
  min-width: 80px;
}

.suggestion-item:hover {
  background-color: #f1edf0;
  border-color: #714B67;
}

.suggestion-icon {
  font-size: 24px;
  color: #714B67;
}

.suggestion-text {
  font-size: 12px;
  color: #666;
  font-weight: 500;
}

.footer-info {
  border-top: 1px solid #f0f0f0;
  padding-top: 20px;
}

.update-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: #999;
  margin: 0;
}

.update-icon {
  font-size: 14px;
}

.mr-2 {
  margin-right: 8px;
}

/* 动画效果 */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .under-development-content {
    padding: 40px 20px;
  }
  
  .title {
    font-size: 24px;
  }
  
  .action-section {
    flex-direction: column;
    align-items: center;
  }
  
  .action-section .el-button {
    width: 200px;
  }
  
  .suggestions-grid {
    gap: 12px;
  }
  
  .suggestion-item {
    min-width: 60px;
    padding: 12px;
  }
}
</style>
